/**
 * struct TreeNode {
 *	int val;
 *	struct TreeNode *left;
 *	struct TreeNode *right;
 *	TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 * };
 */
#include <queue>
class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * 
     * @param pRoot TreeNode类 
     * @return TreeNode类
     */
    TreeNode* MirrorHelper(TreeNode* root)
    {
        if(root == nullptr)
        {
            return nullptr;
        }
        MirrorHelper(root->left);//镜像左子树
        MirrorHelper(root->right);//镜像右子树
        swap(root->left,root->right);//交换两个子树
        return root;
    }
    TreeNode* Mirror(TreeNode* pRoot) {
       return MirrorHelper(pRoot);
    }
};